/* 
 * File:   Walker.h
 * Author: paula
 *
 * Created on 14 de noviembre de 2014, 14:39
 */

#ifndef WALKER_H
#define	WALKER_H

#include <string>
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "../Define/DefaultValues.h"
#include "../Define/Structs.h"
#include "../Controller/SBSLog.h"
#include "ClientSocket.h"
#include "SBSImage.h"
#include "Dot.h"
#include "Drawable.h"
#include "Walker.h"

class Walker : public Drawable {
public:
    Walker();
    Walker(int x, int y, SDL_Renderer** gRenderer, int character);
    Walker(const Walker& orig);
    virtual ~Walker();

    float getPosX();
    float getPosY();

    bool isJumping();
    bool isKneeling();
    bool isFallingDown();
    bool isWalking();
    bool isWalkingRight();
    bool isWalkingLeft();

    void keepKneeling();
    void keepJumping();
    void keepWalking();
    void keepFallingDown();

    void stopKneeling();
    void stopWalking();

    void jump();
    void wait();
    void kneel();
    void walkRight();
    void walkLeft();

    void setJumping();
    void setKneeling();
    void setFalling();
    void setWalking();
    void setWaiting();

    bool getDirectionRight();
    void setDirectionRight(bool direction);

    SDL_Renderer* gRenderer;
    Dot *dot;

    void actualizePosition(float posX, float PosY);

    void loadMedia();
    string path;
    int state;

    int getState();
    int getCharacterId();
    struct ObjectInit getData();
    void updateData(struct ObjectInit data);
    void freeMedia();
    
    void draw();

    struct ObjectInit data;

protected:

    SBSImage* principalR;
    SBSImage* principalR0;
    SBSImage* principalR1;
    SBSImage* principalR2;
    SBSImage* principalR3;
    SBSImage* principalR4;
    SBSImage* principalDR1;
    SBSImage* principalDR2;
    SBSImage* principalDR3;
    SBSImage* principalUR1;
    SBSImage* principalUR2;
    SBSImage* principalUR3;
    
    SBSImage* imageToDraw;

    bool wasJumping;
    bool beginning;
    bool jumping, kneeling, fallingDown, walking, waiting;
    int counterWalk, counterWalkII, counterKneel, counterJump, counterWait;
    int rot;

    bool directionRight;
    void changeImage(SBSImage* image, float rot);

    float constFall;
    float initConsFall;

    float velocityWalkLeft;
    float velocityWalkRight;

};

#endif	/* WALKER_H */

